package com.carkeeper.feign;


import com.carkeeper.entity.Result;
import com.carkeeper.pojo.KnowledgeBaseInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@Repository
@FeignClient(name = "knowledge")
public interface KnowledgeFeign {

    /**
     * 创建索引库
     * @return
     */
    @GetMapping("/esKnowledge/createES")
    public Result createElasticsearch();


    /**
     * 批量导入
     * @return
     */
    @PostMapping("/esKnowledge/batchSingleAddES")
    public Result batchSingleAddES();


    /**
     * KnowledgeBaseInfo列表查询
     *
     * @param map
     * @return
     */
    @GetMapping("/knowledge/showAllKnowledge/{currentPage}/{pageSize}")
    public Result<List<KnowledgeBaseInfo>> showAllKnowledge(@RequestParam Map<String, String> map, @PathVariable("currentPage") String currentPage, @PathVariable("pageSize") String pageSize);


    /**
     * 查询全部分类
     *
     * @return
     */
    @GetMapping("/knowledge/showCategory")
    public Result<Map<String, List<String>>> findCategory(@RequestParam Map map);


    /**
     * 添加推文
     * @param knowledgeBaseInfo
     * @return
     */
    @PostMapping("/knowledge/add")
    public Result addKnowledgeBaseInfo(@RequestBody KnowledgeBaseInfo knowledgeBaseInfo);


    /**
     * 更新推文
     *
     * @param knowledgeBaseInfo
     * @return
     */
    @PutMapping("/knowledge/update")
    public Result update(@RequestBody KnowledgeBaseInfo knowledgeBaseInfo);


    /**
     * 删除推文
     *
     * @param id
     * @return
     */
    @DeleteMapping("/knowledge/delete/{id}")
    public Result delete(@PathVariable("id") Long id);


    /**
     * 根据分类查询知识库
     *
     * @param type
     * @return
     */
    @GetMapping("/knowledge/findKnowledgeByCategory/{type}")
    public Result<List<KnowledgeBaseInfo>> findKnowledgeByCategory(@PathVariable("type") String type);
}
